package me.exchange.com.modules.log.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @author Zheng Jie
 * @date 2018-11-24
 */
@Entity
@Data
@Table(name = "sys_log")
@NoArgsConstructor
@org.hibernate.annotations.Table(appliesTo = "sys_log",comment="日志信息表")
public class Log  implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(name = "id",value = "ID",required = false)
    private Long id;

    /** 操作用户 */
    @Column(name = "username")
    @ApiModelProperty(name = "username",value = "操作用户",required = false)
    private String username;

    /** 模块描述 */
    @Column(name = "description")
    @ApiModelProperty(name = "description",value ="模块描述",required = false)
    private String description;

    /** 方法名 */
    @Column(name = "method")
    @ApiModelProperty(name = "method",value = "方法名",required = false)
    private String method;

    /** 参数 */
    @Column(columnDefinition = "text",name = "params")
    @ApiModelProperty(name = "params",value = "参数",required = false)
    private String params;

    /** 日志类型 */
    @Column(name = "log_type")
    @ApiModelProperty(name = "logType",value = "日志类型",required = false)
    private String logType;

    /** 请求ip */
    @Column(name = "request_ip")
    @ApiModelProperty(name = "requestIp",value = "请求ip",required = false)
    private String requestIp;

    /** 地址 */
    @Column(name = "address")
    @ApiModelProperty(name = "address",value = "地址",required = false)
    private String address;

    /** 浏览器  */
    @Column(name = "browser")
    @ApiModelProperty(name = "browser",value = "浏览器",required = false)
    private String browser;

    /** 请求耗时 */
    @Column(name = "time")
    @ApiModelProperty(name = "time",value = "请求耗时",required = false)
    private Long time;

    /** 异常详细  */
    @Column(name = "exception_detail", columnDefinition = "text")
    private byte[] exceptionDetail;

    /** 创建日期 */
    @CreationTimestamp
    @Column(name = "c_admin_time")
    @ApiModelProperty(name = "cAdminTime",value = "创建日期",required = false)
    private Timestamp cAdminTime;

    /**
     * 资源编码
     */
    @Column(name = "resources_code")
    @ApiModelProperty(name = "resourcesCode",value = "资源编码",required = false)
    private String resourcesCode;

    public Log(String logType, Long time) {
        this.logType = logType;
        this.time = time;
    }
}
